home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
boxingbagChar.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
3KB
|
138 lines
-- boxing character state machine
beginStateMachine()
onEnter(function(msg)
local bag = getStateObjectFromID(msg.sender);
storeStateObject("bag", bag);
if (bag) then
-- bag does exist
local actionPointName = retrieveData("actionPointName");
local actionPoint = getParent().getFreeActionPoint(bag, actionPointName);
if (not actionPoint) then
-- action points is locked
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
else
getParent().lockActionPoint(bag, actionPointName);
end
else
-- sink does not exist anymore
getParent().setEmoticon(EMOTICON_CANNOT, EMOTICON_DELAY);
sendMsg("emoThink", getParent().walkSO);
exitStateMachine();
end
freeHands(getParent());
end )
onExit(function(msg)
-- local bag = retrieveStateObject("bag");
-- if (bag) then
-- getParent().stopAllActivities(bag);
-- getParent().unlockActionPoints(bag);
-- removeStateObject("bag");
-- end
unlockAll("bag");
end )
state("boxStart")
onEnter(function(msg)
startAnimation("boxingStart");
end )
onMsg("end", function(msg)
if testCancel() then
setState("boxStop")
else
setState("box")
end
end )
state("box")
onEnter(function(msg)
local bag = retrieveStateObject("bag");
local box = getParent().startActivity("box", bag);
length, scale = getActivityLength(box);
storeData("scale", scale);
sendDelayedMsgThis("stopBoxing", length);
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
sendMsgThis("startLoop");
local others = getOtherUsers(getParent(), bag, "box");
if (not others[1]) then
bag.loopSound("boxingBag");
end;
end )
onExit(function(msg)
local bag = retrieveStateObject("bag");
bag.stopSound("boxingBag");
end )
onMsg("startLoop", function(msg)
startAnimation("boxing", false, retrieveData("scale", 1.0));
sendDelayedMsgThis("punch", 2800);
sendDelayedMsgThis("punch", 3100);
sendDelayedMsgThis("punch", 3400);
sendDelayedMsgThis("punch", 4850);
sendDelayedMsgThis("punch", 5450);
sendDelayedMsgThis("punch", 6200);
sendDelayedMsgThis("punch", 6770);
sendDelayedMsgThis("punch", 7150);
sendDelayedMsgThis("punch", 7860);
end )
onMsg("punch", function(msg)
getParent().playSound("punch" .. random(1,2));
end )
onMsg("stopBoxing", function(msg)
setState("boxStop")
end )
onMsg("testCancel", function(msg)
if testCancel() or (not this.getParent().getCurrentActivityGain()) then
setState("boxStop")
else
sendDelayedMsgThis("testCancel", CANCEL_POLLING_INTERVAL);
end
end )
onMsg("end", function(msg)
if testCancel() then
setState("boxStop")
else
sendMsgThis("startLoop");
end
end )
state("boxStop")
onEnter(function(msg)
startAnimation("boxingStart", false, -1.0);
end )
onMsg("end", function(msg)
exitAndGoAway();
end )
endStateMachine()